package org.swxjava.util;

class SystemOutLogWrapper implements Log {

	private String targetClassName = null;

	protected SystemOutLogWrapper(Class clazz) {
		if (clazz != null) {
			targetClassName = clazz.getSimpleName();
		}
	}

	private void message(String level, Object msg, Throwable th) {
		message(level, msg);
		if (th != null)
			th.printStackTrace();
	}

	private void message(String level, Object msg) {
		System.out.println("[" + level + "][" + targetClassName + "] " + msg);
	}

	public void debug(Object arg0, Throwable arg1) {
		message("DEBUG", arg0, arg1);
	}

	public void debug(Object arg0) {
		message("DEBUG", arg0);
	}

	public void error(Object arg0, Throwable arg1) {
		message("ERROR", arg0, arg1);
	}

	public void error(Object arg0) {
		message("ERROR", arg0);
	}

	public void fatal(Object arg0, Throwable arg1) {
		message("FATAL", arg0, arg1);
	}

	public void fatal(Object arg0) {
		message("FATAL", arg0);
	}

	public void info(Object arg0, Throwable arg1) {
		message("INFO ", arg0, arg1);
	}

	public void info(Object arg0) {
		message("INFO ", arg0);
	}

	public boolean isDebugEnabled() {
		return true;
	}

	public boolean isErrorEnabled() {
		return true;
	}

	public boolean isFatalEnabled() {
		return true;
	}

	public boolean isInfoEnabled() {
		return true;
	}

	public boolean isTraceEnabled() {
		return true;
	}

	public boolean isWarnEnabled() {
		return true;
	}

	public void trace(Object arg0, Throwable arg1) {
		message("TRACE", arg0, arg1);
	}

	public void trace(Object arg0) {
		message("TRACE", arg0);
	}

	public void warn(Object arg0, Throwable arg1) {
		message("WARN ", arg0, arg1);
	}

	public void warn(Object arg0) {
		message("WARN ", arg0);
	}
}
